package com.utils;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;



public class DBUtil {
private static String driver;
private static String user;
private static String password;
private static String url;
private static Connection con;

      static{
    	  Properties p = new Properties();
    	  InputStream in = DBUtil.class.getResourceAsStream("db.properties");
    	  try {
			p.load(in);
			driver = p.getProperty("driver");
			user = p.getProperty("user");
			password = p.getProperty("password");
			url = p.getProperty("url");
			Class.forName(driver);
			con = (Connection) DriverManager.getConnection(url, user, password);
			System.out.println("数据库连接成功");
		} catch (Exception e) {
		
			e.printStackTrace();
		}
      }
      public static Connection getCon(){
    	  return con;
    	  } 
      }